package com.qust.edu.aliyun.controller;

import com.qust.edu.aliyun.dto.UserDto;
import com.qust.edu.aliyun.pojo.User;
import com.qust.edu.aliyun.service.UserService;
import com.qust.edu.aliyun.vo.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * projectName: aliyun_guanli
 *
 * @author: 孙春娟
 * time: 2021/9/28 10:16
 * description:
 */
@RestController
@CrossOrigin("*")
@RequestMapping("users")
public class UserController  {

    @Autowired
    private UserService userService;

    /**
     * 登录
     * @param userDto
     * @return
     */
 @PostMapping("login")
    public Object login(@RequestBody UserDto userDto){
     R r = userService.login(userDto);

     return r;
 }

    /**
     * 检查用户是可以注册接口
     * @param userDto
     * @return
     */
    @PostMapping("findUserName")
    public Object findUserName(@RequestBody UserDto userDto){
        R r = userService.findUserName(userDto);



        return  r;
    }

    /**
     * 注册接口
     * @param userDto
     * @return
     */
    @PostMapping("register")
    public Object register(@RequestBody UserDto userDto){
        R r = userService.register(userDto);

        //3.负责将业务的返回值，传回给前端

        return  r;
    }

    /**
     * 查询所有管理员
     * @return
     */
    @PostMapping("findAllUsers")
    public Object findAllUsers(){
        R r = userService.findAllUsers();
        return r;
    }
    /**
     * 添加管理员
     * @return
     */
    @PostMapping("getAddManage")
    public Object getAddManage(@RequestBody User user){
        R r = userService.getAddManage(user);
        return r;
    }

    /**
     * 删除管理员
     * @return
     */
    @PostMapping("getDeleteManage")
    public Object getDeleteManage(@RequestBody UserDto userDto){
        R  r = userService.getDeleteManage(userDto);
        return r;
    }

    /**
     * 修改管理员R
     * @return
     */
    @PostMapping("getModifyManage")
    public Object getModifyManage(@RequestBody User user){
        R r = userService.getModifyManage(user);
        return r;
    }


}
